package beans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import util.ConnectionDataSource;

public class DossierInfractionBean {
	public void addInfraction(Long dossierID, int infractionID)
			throws SQLException {
		ConnectionDataSource cds = new ConnectionDataSource();
		Connection conn = cds.getSimpleConnection();
		PreparedStatement pstmt = null;
		try {
			String query = "INSERT INTO \"DossierIntractions\"(\"DossierID\", \"InfractionID\") VALUES (?, ?);";
			pstmt = conn.prepareStatement(query); // create a statement
			pstmt.setLong(1, dossierID); // set input parameter 1
			pstmt.setInt(2, infractionID); // set input parameter 2
			pstmt.executeUpdate(); // execute insert statement
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (pstmt != null && !pstmt.isClosed()) {
				pstmt.close();
			}
			if (conn != null && !conn.isClosed()) {
				conn.close();
			}
		}

	}
}
